Skip to content

SDK | Upgrade AWS SDK to v3 - Block Store S3 #9067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

naveenpaul1
Copy link
Contributor

@naveenpaul1 naveenpaul1 commented Jun 6, 2025

Describe the Problem

Upgrade AWS SDK to v3 - Block Store S3

Explain the Changes

  1. update SDK version to V3 for block_store_s3.js
  2. STS flow updated with new SDK v3.

Issues: Fixed #xxx / Gap #xxx

  1. remove deprecated SDK v2 from block store s3 flow.

Testing Instructions:

  1. Test bulk storage flow
  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • New Features

    • Added support for AWS SDK v3 for S3 interactions, including new methods for creating S3 clients and generating STS credentials.
  • Chores

    • Updated dependencies to include AWS SDK v3 packages.

Copy link

coderabbitai bot commented Jun 10, 2025

"""

Walkthrough

This change migrates S3-related functionality from AWS SDK v2 to AWS SDK v3. It updates the BlockStoreS3 class and introduces new utility functions for STS-based S3 client creation using the v3 SDK. Dependencies for the new AWS SDK packages are added to package.json. The test suite is extended to cover the new SDK v3 implementations.

Changes

Files/Paths Change Summary
package.json Added @aws-sdk/credential-providers and @aws-sdk/s3-request-presigner to dependencies.
src/agent/block_store_services/block_store_s3.js Migrated S3 operations from AWS SDK v2 to v3, updating client instantiation and method calls.
src/util/cloud_utils.js Added createSTSS3SDKv3Client and generate_aws_sdkv3_sts_creds for AWS SDK v3 STS/S3 usage.
src/test/unit_tests/util_functions_tests/test_cloud_utils.js Added tests for AWS SDK v3 STS credentials generation and S3 client creation; adjusted stubs.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant cloud_utils.js
    participant AWS STS
    participant AWS S3

    Caller->>cloud_utils.js: createSTSS3SDKv3Client(params, additionalParams)
    cloud_utils.js->>cloud_utils.js: generate_aws_sdkv3_sts_creds(params, roleSessionName)
    cloud_utils.js->>AWS STS: AssumeRoleWithWebIdentity
    AWS STS-->>cloud_utils.js: Credentials
    cloud_utils.js->>cloud_utils.js: Instantiate S3 client with credentials
    cloud_utils.js-->>Caller: S3 client instance
    Caller->>AWS S3: S3 operations using v3 client
Loading

Possibly related PRs

  • SDK | Upgrade AWS SDK to v3 - Unit tests #9042: The main PR and the retrieved PR both perform a migration from AWS SDK v2 to AWS SDK v3, specifically updating S3 client usage and configuration patterns, including replacing .promise() calls with direct promise returns and adjusting credential and HTTP handler setups, indicating a direct and strong code-level relation in the AWS SDK upgrade approach.

Suggested labels

size/XXL

Suggested reviewers

  • tangledbytes
  • romayalon
  • liranmauda
  • jackyalbo
    """

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-07-16T04_31_02_474Z-debug-0.log


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b79454 and 9f61f6c.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • package.json (1 hunks)
  • src/agent/block_store_services/block_store_s3.js (17 hunks)
  • src/test/unit_tests/util_functions_tests/test_cloud_utils.js (2 hunks)
  • src/util/cloud_utils.js (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • package.json
  • src/test/unit_tests/util_functions_tests/test_cloud_utils.js
  • src/agent/block_store_services/block_store_s3.js
  • src/util/cloud_utils.js
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@naveenpaul1 naveenpaul1 force-pushed the block_store_ser_sdkv3 branch 5 times, most recently from e811dd7 to c9c3fde Compare June 17, 2025 13:32
@naveenpaul1 naveenpaul1 marked this pull request as ready for review June 23, 2025 05:54
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 46554f9 and c9c3fde.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • package.json (1 hunks)
  • src/agent/block_store_services/block_store_s3.js (14 hunks)
  • src/test/unit_tests/test_cloud_utils.js (3 hunks)
  • src/util/cloud_utils.js (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`src/test/**/*.*`: Ensure that the PR includes tests for the changes.

src/test/**/*.*: Ensure that the PR includes tests for the changes.

  • src/test/unit_tests/test_cloud_utils.js
🔇 Additional comments (13)
package.json (1)

85-85: Verify if aws-sdk v2 is still needed.

The old AWS SDK v2 dependency is still present. If this upgrade is intended to remove v2 usage from the Block Store S3 component, verify if this dependency is still needed elsewhere in the codebase.

#!/bin/bash
# Description: Check if aws-sdk v2 is still used in the codebase
# Expect: If only used in files not related to this PR, it's safe to keep

echo "Checking aws-sdk v2 usage in the codebase:"
rg -A 3 "require\('aws-sdk'\)" --type js

echo -e "\nChecking AWS.S3 usage:"
rg -A 3 "AWS\.S3" --type js

echo -e "\nChecking new AWS SDK v3 usage:"
rg -A 3 "@aws-sdk/" --type js
src/test/unit_tests/test_cloud_utils.js (4)

7-7: LGTM: Import correctly updated for SDK v3.

The import has been properly updated to use the modular AWS SDK v3 client.


25-32: LGTM: Stubbing correctly updated for SDK v3.

The stubbing approach is correctly updated to mock the send method on STSClient.prototype, which is the proper way to stub SDK v3 client calls.


49-49: Verify the timeout extension rationale.

The timeout was extended from the default to 50 seconds. Ensure this is necessary for STS operations or if there are specific performance considerations.


59-63: LGTM: Correctly handles asynchronous credential access.

The test properly uses await to access credentials and region from the S3 client configuration, which is required for SDK v3.

src/agent/block_store_services/block_store_s3.js (5)

5-5: LGTM: Import correctly updated for SDK v3.

The import has been properly updated to use the modular AWS SDK v3 S3 client.


15-15: LGTM: Added proper HTTP handler import.

The NodeHttpHandler import is correctly added for SDK v3 HTTP configuration.


43-54: LGTM: S3 client instantiation correctly updated for SDK v3.

The S3 client configuration is properly updated with:

  • Credentials passed as an object
  • forcePathStyle instead of s3ForcePathStyle
  • Proper requestHandler configuration with NodeHttpHandler

61-72: LGTM: S3 compatible endpoint configuration updated correctly.

The configuration for S3-compatible endpoints is properly updated with:

  • applyChecksum replacing the deprecated s3DisableBodySigning
  • Proper HTTP agent configuration through requestHandler

82-85: LGTM: S3 method calls correctly updated for SDK v3.

All S3 method calls have been properly updated by removing the .promise() chaining, which is correct since SDK v3 methods return promises natively.

Also applies to: 109-112, 167-170, 194-199, 241-248, 265-268, 309-315, 325-328, 345-350, 353-358, 389-396, 424-427

src/util/cloud_utils.js (3)

13-14: LGTM: Imports correctly updated for SDK v3.

The imports have been properly updated to include the modular AWS SDK v3 STS client and commands, along with the NodeHttpHandler.


36-44: LGTM: S3 client creation correctly updated for SDK v3.

The createSTSS3Client function is properly updated with:

  • New S3 client from SDK v3
  • Proper requestHandler configuration
  • forcePathStyle instead of the deprecated s3ForcePathStyle

49-67: LGTM: STS credential generation correctly updated for SDK v3.

The generate_aws_sts_creds function is properly updated with:

  • STSClient instantiation with region configuration
  • AssumeRoleWithWebIdentityCommand usage
  • Proper credential extraction from the response
  • Maintained error handling and validation

@naveenpaul1 naveenpaul1 force-pushed the block_store_ser_sdkv3 branch 3 times, most recently from 139e101 to 80d4fc2 Compare June 25, 2025 08:23
@naveenpaul1 naveenpaul1 marked this pull request as draft June 25, 2025 12:12
@naveenpaul1
Copy link
Contributor Author

naveenpaul1 commented Jun 25, 2025

after this PR, STS request in namespace_s3 is failing, Will update the Namespce_s3 SDK version aslo.
Moving this PR to draft

@naveenpaul1 naveenpaul1 force-pushed the block_store_ser_sdkv3 branch 3 times, most recently from f68832b to a1cda69 Compare July 10, 2025 12:34
@naveenpaul1 naveenpaul1 marked this pull request as ready for review July 10, 2025 12:35
@naveenpaul1 naveenpaul1 force-pushed the block_store_ser_sdkv3 branch 3 times, most recently from 24e3bec to 6b79454 Compare July 15, 2025 13:08
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 24e3bec and 6b79454.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • package.json (1 hunks)
  • src/agent/block_store_services/block_store_s3.js (17 hunks)
  • src/test/unit_tests/util_functions_tests/test_cloud_utils.js (2 hunks)
  • src/util/cloud_utils.js (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • package.json
  • src/util/cloud_utils.js
  • src/agent/block_store_services/block_store_s3.js
🧰 Additional context used
📓 Path-based instructions (1)
src/test/**/*.*

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-package-lock-validation
  • GitHub Check: run-jest-unit-tests
🔇 Additional comments (3)
src/test/unit_tests/util_functions_tests/test_cloud_utils.js (3)

10-11: LGTM! Correct imports for AWS SDK v3 testing.

The imports are appropriate for testing AWS SDK v3 functionality - STSClient for STS operations and fs for file system stubbing.


19-19: Good practice to use a constant for the region.

This avoids hardcoding the region value and improves maintainability.


110-125: LGTM! Proper async credential handling for AWS SDK v3.

The test correctly handles the async nature of credentials in AWS SDK v3 by using await for s3.config.credentials() and s3.config.region() calls. This is the correct approach for testing v3 client configuration.

Signed-off-by: naveenpaul1 <napaul@redhat.com>
Signed-off-by: Naveen Paul <napaul@redhat.com>
@naveenpaul1 naveenpaul1 force-pushed the block_store_ser_sdkv3 branch from 6b79454 to 9f61f6c Compare July 16, 2025 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant